﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;

namespace TestPlanWordWriter.Common.Word
{
    [Serializable]
    public class TestPlanDocWriterSettings
    {
        public string TestPlanStyleName { get; set; }
        public string TestPlanDescriptionStyleName { get; set; }

        public List<TestSuiteSettings> TestSuiteLevelsSettings { get; set; }

        public string TestCaseStyleName { get; set; }
        public string TestCaseDescriptionStyleName { get; set; }

        public string TestStepsTableStyleName { get; set; }
        public string TestResultsTableStyleName { get; set; }

        public string TableLabel_Step { get; set; }
        public string TableLabel_Action { get; set; }
        public string TableLabel_ExpectedResult { get; set; }

        public string TableLabel_Results_ResultOutcome { get; set; }
        public string TableLabel_Results_ConfigurationName { get; set; }
        public string TableLabel_Results_DateStarted { get; set; }
        public string TableLabel_Results_DateCompleted { get; set; }
        public string TableLabel_Results_Comment { get; set; }

        public void ExportToFile(string filePath)
        {
            using (Stream fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(TestPlanDocWriterSettings));
                serializer.Serialize(fileStream, this);
            }
        }

        public static TestPlanDocWriterSettings CreateFromFile(string filePath)
        {
            using (Stream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(TestPlanDocWriterSettings));
                object settingsObject = serializer.Deserialize(fileStream);
                return settingsObject as TestPlanDocWriterSettings;
            }
        }
    }
}
